home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 4 / FM Towns Free Software Collection 4 - Disc 1.iso / t_os / wstype / source / scroll.c < prev    next >
C/C++ Source or Header  |  1991-10-18  |  3KB  |  162 lines

  1. /***   [scroll.c]
  2. *
  3. *    スクロールスピードインターフェイスウィンドウ        (C)ささがわ
  4. *
  5. *    For GNU C Compiler (GCC)   Version 1.39
  6. *
  7. ***/
  8.  
  9. #include <stdio.h>
  10. #include "graph.h"
  11. #include "mos.h"
  12. #include "window.h"
  13. #include "icn.h"
  14. #include "txwind.h"
  15. #include "optparse.h"
  16. #include "others.h"
  17.  
  18. #define WH_CAN        1
  19. #define WH_TITLE    2
  20. #define WH_ON        3
  21. #define WH_OTHER    0
  22.  
  23. extern int    PAL_Back;
  24. extern int    PAL_Black;
  25. static int    wx, wy;
  26. static int    SPEED;
  27.  
  28. static void    Draw_window(void);
  29. static int    Where(int, int);
  30. static void on(int);
  31. static void off(int);
  32.  
  33. void SCR_init(void) {
  34.     SPEED = OPT_Scroll();
  35.     if (SPEED < 0 || 4 < SPEED)    SPEED = 2;
  36.     TXW_rollset(SPEED);
  37. }
  38.  
  39. int WIND_schroll(void) {
  40.     int        ret = 0, spd;
  41.     struct RECT    a, b;
  42.     
  43.     wx = 188;
  44.     wy = 149;
  45.     a.x1 = 319;    a.y1 = 259;
  46.     a.x2 = 320;    a.y2 = 260;
  47.     b.x1 = wx;    b.y1 = wy;
  48.     b.x2 = wx + 263;    b.y2 = wy + 181;
  49.     afterImage(&a, &b);
  50.     
  51.     Draw_window();
  52.     spd = SPEED;
  53.     MOS_disp(0);
  54.     on(spd);
  55.     MOS_disp(1);
  56.     while (!ret) {
  57.         char    mb;
  58.         int        mx, my, wh;
  59.         
  60.         CLOCK(0);
  61.         if (MOS_rdpos(&mb, &mx, &my), !(mb & 1))
  62.             continue;
  63.         
  64.         if ((wh = Where(mx, my)) == WH_CAN) {
  65.             if (Button(wx + 6, wy + 6, wx + 25, wy + 25))
  66.                 ret = -1;
  67.         } else if (wh == WH_ON) {
  68.             if (Button(wx + 167, wy + 148, wx + 246, wy + 169)) {
  69.                 SPEED = spd;
  70.                 ret = 1;
  71.             }
  72.         } else if (wh == WH_TITLE) {
  73.             struct RECT    s, w;
  74.             
  75.             w.x1 = wx;    w.y1 = wy;
  76.             w.x2 = wx + 263;    w.y2 = wy + 181;
  77.             s.x1 = 0;    s.y1 = 40;    s.x2 = 639;    s.y2 = 463;
  78.             if (dragWindow(mx, my, &w, &s, 0, 0)) {
  79.                 wx = w.x1;    wy = w.y1;
  80.                 MOS_disp(0);
  81.                 EGB_cls(0);
  82.                 MOS_disp(1);
  83.                 Draw_window();
  84.                 MOS_disp(0);
  85.                 on(spd);
  86.                 MOS_disp(1);
  87.             }
  88.         } else if (wh >= 10) {
  89.             if (wh - 10 != spd) {
  90.                 MOS_disp(0);
  91.                 off(spd);
  92.                 on(spd = wh - 10);
  93.                 MOS_disp(1);
  94.             }
  95.         } else {
  96.             while (MOS_rdpos(&mb, &mx, &my), mb & 1);
  97.         }
  98.     }
  99.     
  100.     if (ret == 1) {
  101.         TXW_rollset(SPEED);
  102.         return SPEED;
  103.     } else
  104.         return -1;
  105. }
  106.  
  107. static void Draw_window(void) {
  108.     int        i;
  109.     struct opnwin_t    opw;
  110.     
  111.     opw.title = "スクロール スピード";
  112.     opw.x1 = wx;
  113.     opw.y1 = wy;
  114.     opw.x2 = opw.x1 + 263;
  115.     opw.y2 = opw.y1 + 181;
  116.     opw.shdw = 1;
  117.     opw.canb = 1;
  118.     opw.nopt = 0;
  119.     opw.wopt = NULL;
  120.     opw.expb = 0;
  121.     opw.ord = 0;
  122.     MOS_disp(0);
  123.     drawWindow(&opw);
  124.     
  125.     EGB_str2("○ 最  高  速", wx + 80, wy + 56, PAL_Black);
  126.     EGB_str2("○     ↑    ", wx + 80, wy + 76, PAL_Black);
  127.     EGB_str2("○  中    速 ", wx + 80, wy + 96, PAL_Black);
  128.     EGB_str2("○     ↓    ", wx + 80, wy + 116, PAL_Black);
  129.     EGB_str2("○ 最  低  速", wx + 80, wy + 136, PAL_Black);
  130.     DrawButton(1, wx + 166, wy + 147, wx + 247, wy + 170);
  131.     for (i = 0; i < 2; i++)
  132.         EGB_str2(" 実    行 ", wx + 167 + i, wy + 166, PAL_Black);
  133.     MOS_disp(1);
  134. }
  135.  
  136. static int Where(int x, int y) {
  137.     int        i, ret;
  138.     
  139.     x -= wx;
  140.     y -= wy;
  141.     if (5 < x && x < 26 && 5 < y && y < 26)
  142.         ret = WH_CAN;
  143.     else if (26 < x && x < 258 && 5 < y && y < 26)
  144.         ret = WH_TITLE;
  145.     else if (166 < x && x < 247 && 147 < y && y < 170)
  146.         ret = WH_ON;
  147.     else if (80 <= x && x <= 183 && (i = y - 41) >= 0 && i / 20 < 5 && i % 20 < 16)
  148.         ret = i / 20 + 10;
  149.     else
  150.         ret = WH_OTHER;
  151.     
  152.     return ret;
  153. }
  154.  
  155. static void on(int spd) {
  156.     EGB_str3("●", wx + 80, wy + 56 + spd * 20, PAL_Black, PAL_Back);
  157. }
  158.  
  159. static void off(int spd) {
  160.     EGB_str3("○", wx + 80, wy + 56 + spd * 20, PAL_Black, PAL_Back);
  161. }
  162.